#include <bits/stdc++.h>
using namespace std;
int t,n;
const int N=1e5+50;
int a[N];
int main(void){
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);;
        memset(a,0,sizeof(a));
        for(int i=0;i<n;i++){
            scanf("%d",&a[i]);
        }
        printf("%d\n",int(floor(sqrt(abs(a[n-1]-a[0])))));
    }
    return 0;
}